package cn.itcast.bos.dao.system;

import cn.itcast.bos.domain.system.Menu;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface MenuRepositor extends JpaRepository<Menu,Integer> {

    @Query(value = "SELECT m2.* FROM t_menu m INNER JOIN t_role_menu trm ON m.C_ID = trm.C_MENU_ID INNER JOIN t_role r ON trm.C_ROLE_ID = r.C_ID " +
            "INNER  JOIN t_user_role tur ON r.C_ID = tur.C_ROLE_ID JOIN t_menu m2 ON m.C_ID = m2.C_PID WHERE tur.C_USER_ID = ?",nativeQuery = true)
    public List<Menu> findMenuById(Integer Uid);
}
